<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="recording and transcoding system">
    <meta name="author" content="typefo">
    <link rel="icon" href="favicon.ico">
    <title>pbxMon System</title>
    <link type="text/css" rel="stylesheet" href="/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link type="text/css" rel="stylesheet" href="/css/system.css">
  </head>
  <body>
    <nav class="navbar navbar-default navbar-static-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand">
            <img alt="Brand" src="/img/logo.png" width="34" style="margin-top:-8px" />
          </a>
          <a class="navbar-brand">pbxMon</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li><a href="/cdr">通话记录</a></li>
            <li><a href="/server">网关管理</a></li>
            <li><a href="/route">路由管理</a></li>
            <li><a href="/interface">接口管理</a></li>
            <li><a href="/report">数据报表</a></li>
            <li><a href="/system/status">服务器状态</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="/system/option"><span class="glyphicon glyphicon-cog"></span> 系统设置</a></li>
            <li><a href="/logout"><span class="glyphicon glyphicon-log-out"></span> 退 出</a></li>
          </ul>
        </div>
      </div>
    </nav>
    <div class="container">
      <div class="row">
        <ol class="breadcrumb">
          <li><a href="/cdr">Home</a></li>
          <li><a href="#">System</a></li>
          <li class="active">Firewall</li>
          <li class="pull-right help"><span class="glyphicon glyphicon-question-sign"></span> <a href="#">帮助信息</a></li>
        </ol>
      </div>
    </div>
    <div class="container">
      <div class="row">
        <ul class="nav nav-tabs">
          <li role="presentation"><a href="/system/option">常规选项</a></li>
          <li role="presentation" class="active"><a href="/system/security">防火墙</a></li>
          <li role="presentation"><a href="/system/password">修改密码</a></li>
          <li role="presentation"><a href="/system/about">关于系统</a></li>
          <li class="pull-right" role="presentation"><a class="text-muted" href="javascript:void(0);" onclick="show()"><span class="glyphicon glyphicon-plus"></span> 添加 IP</a></li>
        </ul>
      </div>
      <div class="row box">
        <table class="table table-condensed table-hover">
        <tbody>
        <?php
        if (isset($data)) {
          foreach ($data as $obj) {
            echo '<tr><td class="tab-left" style="width:50px"><span class="glyphicon glyphicon-lock text-success"></span></td><td class="text-left" style="width:200px">',long2ip($obj['ip']),'</td><td><small class="text-muted"> 创建于 ',date('Y-m-d H:i:s', $obj['create_time']),'</small> <button type="button" class="close" onClick="drop(',$obj['ip'],')" aria-label="Close"><span>&times;</span></button></td>',"\n";
          }
        }
        ?>
        </tbody>
        </table>
      </div>
    </div>
  </body>
  <script type="text/javascript" src="/js/jquery.min.js"></script>
  <script type="text/javascript" src="/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/js/layer.js"></script>
  <script type="text/javascript">
  function drop(ip) {
    layer.confirm('亲，确定要删除？', {
        btn: ['是','否'], icon: 3
      }, function(index){
        var url = '/system/security?op=delete&ip=' + ip;
        $.get(url, function(response, status){
          if (status == 'success') {
            layer.close(index);
            window.location.reload();
          } else {
            layer.msg('Oops, 删除失败!', {icon: 2});
          }
        });
     });
  }

  function show() {
    layer.prompt({title: '输入被允许的 ip 地址'}, function(val, index){
      var url = '/system/security';
      $.post(url, {ip: val}, function(response, status) {
        if (status == 'success') {
          layer.close(index);
          window.location.reload();
        } else {
          layer.msg('Oops, 添加 ' + ip + ' 失败!', {icon: 2});
        }
      });
    });
  }
  </script>
</html>
